#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main() 
{
	int a;
	scanf("%d",&a);
	int sum = a;
	while (a > 1)
	{
		a /= 2;
		sum += a;
	}
	printf("%d",sum);

}